package com.example.tests;

import java.util.Random;
import org.testng.annotations.Test;
import com.example.fw.Folders;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;

public class FolderRemovalTests extends TestBase {

	@Test
	public void testFolderDeletion() {
		Folders oldFolders = app.getFolderHelper().getFolders();

		if (oldFolders.size() > 0) {
			Random rnd = new Random();
			int index = rnd.nextInt(oldFolders.size());
			app.getFolderHelper().deleteFolder(index);
			Folders newFolders = app.getFolderHelper().getFolders();
			assertThat(newFolders, equalTo(oldFolders.without(index)));
		} else {
			System.out.println("Empty folder tree");
			try {
				tearDown();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}